package duotai;

public class Test {
}
 class Animal {

    public void eat(){
        System.out.println("吃饭");
    }
    Animal dog(){
        return new Animal();
    }
}
class Dog extends Animal {

    public  void eat(){
        System.out.println("吃狗粮");
    }
    Dog dog(){
        return new Dog();
    }

    public static void main(String[] args) {
        Animal animal = new Dog();//向上转型
        animal.eat();
        System.out.println(animal.dog() instanceof Dog);
    }
}
